package haxe.util;

import haxe.util.Compare;
import haxe.util.SortedCollection;

class NaiveSortedArray<T> extends SortedCollection<T>
{
	public function new( c:Comparator<T> )
	{
		super(c);
	}
	
	public function add(o:T)
	{
		super.add(o);
		_a.reverse();//simply faster with QuickSort
		_a.push(o);
		_a.sort( comp );
	}
	
	public function remove():T
	{
		return _a.shift();
	}
	
	public function removeFirst():T
	{
		return remove();
	}
	
	public function removeLast():T
	{
		return _a.pop();
	}
	
	public function getLast():T
	{
		return _a[_a.length-1];
	}
	
	public function getFirst():T
	{
		return _a[0];
	}
	
	public function toString():String
	{
		return "["+_a.join("|")+"]";
	}
}